// 定义路由表
import { Navigate } from 'react-router-dom'
import Home from './pages/Home'
import About from './pages/About'
import Test1 from './pages/Test1'
import Test2 from './pages/Test2'
import Unknow from './pages/404'
export default [
  {
    path: '/',
    element: <Home></Home>,
  },
  {
    path: 'home',
    element: <Home></Home>,
    children: [
      {
        path: 'test1',
        element: <Test1></Test1>,
      },
      {
        path: 'test2',
        element: <Test2></Test2>,
      },
    ],
  },
  {
    path: 'about',
    children: [
      {
        path: ':id',
        element: <About></About>,
      },
      {
        path: '',
        element: <About></About>,
      },
    ],
  },
  {
    path: '/404',
    element: <Unknow></Unknow>,
  },
  // 当路径发生变化的时候,先和上面的路由规则进行匹配,如果匹配不上,就会走到*这里.*可以和任何匹配不上的路径进行匹配.代表的是所有
  {
    path: '*',
    // 相当于是一个重定向的组件。一旦这个组件执行了就会修改路径
    element: <Navigate to="/404"></Navigate>,
  },
]
